/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.config.controller;

import com.icinfo.cloud.provider.punish.config.dto.ConfigFastCaseMattersDto;
import com.icinfo.cloud.provider.punish.config.dto.ConfigFastProcedureDto;
import com.icinfo.cloud.provider.punish.config.service.IConfigFastCaseMattersService;
import com.icinfo.cloud.provider.punish.config.vo.*;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import com.icinfo.framework.mybatis.pagehelper.generic.PageResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 描述: 【V1.12.1】速结程序配置表 config_fast_case_matters 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2023年08月21日
 */
@RestController
@RequestMapping("/punish/config/fastProcedure")
@Slf4j
public class ConfigFastCaseMattersController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(ConfigFastCaseMattersController.class);

    @Autowired
    private IConfigFastCaseMattersService configFastCaseMattersService;


    /**
     * 获取速结程序列表
     * @param dto
     * @return
     */
    @PostMapping("/fastProcedureList")
    public Result<PageResponse<ConfigFastCaseMattersVo>> fastProcedureList(@RequestBody ConfigFastProcedureDto dto){
        List<ConfigFastCaseMattersVo> list = configFastCaseMattersService.fastProcedureList(dto);
        return Result.success(new PageResponse<>(list));
    }

    /**
     * 新增速结程序
     * @param dto
     * @return
     */
    @PostMapping("/saveFastProcedure")
    public Result saveFastProcedure(@RequestBody @Validated ConfigFastCaseMattersDto dto){
        configFastCaseMattersService.saveFastProcedure(dto);
        return Result.success("新增成功");
    }

    /**
     * 修改速结程序
     * @param dto
     * @return
     */
    @PostMapping("/updateFastProcedure")
    public Result updateFastProcedure(@RequestBody @Validated ConfigFastCaseMattersDto dto){
        configFastCaseMattersService.updateFastProcedure(dto);
        return Result.success("修改成功");
    }

    /**
     * 删除速结程序（逻辑删除）
     * @param dto
     * @return
     */
    @PostMapping("/deleteFastProcedure")
    public Result deleteFastProcedure(@RequestBody ConfigFastProcedureDto dto){
        configFastCaseMattersService.deleteFastProcedure(dto);
        return Result.success("删除成功");
    }

    /**
     * 获取速结程序详情
     * @param dto
     * @return
     */
    @PostMapping("/getFastProcedureDetail")
    public Result getFastProcedureDetail(@RequestBody ConfigFastProcedureDto dto){
        return Result.success(configFastCaseMattersService.getFastProcedureDetail(dto));
    }

    /**
     * 获取处罚事项
     * @param areaCode
     * @return
     */
    @GetMapping("/getPunishmentMatters")
    public Result<List<PunishmentMattersVo>> getPunishmentMatters(String areaCode,String listName){
        return Result.success(configFastCaseMattersService.getPunishmentMatters(areaCode, listName));
    }

    /**
     * 获取认领部门信息
     * @param areaCode
     * @return
     */
    @GetMapping("/getClaimOrg")
    public Result<List<ClaimOrgVo>> getClaimOrg(String areaCode, String orgName){
        return Result.success(configFastCaseMattersService.getClaimOrg(areaCode, orgName));
    }

    /**
     * 根据处罚事项code查询文书模板
     * @param orgCode
     * @param listCode
     * @return
     */
    @GetMapping("/getTemplateByListCode")
    public Result<ConfigFastProcedureVo> getTemplateByListCode(String orgCode, String listCode){
        ConfigFastProcedureVo configFastProcedureVo  = configFastCaseMattersService.getTemplateByListCodeOld(orgCode, listCode);
        return Result.success(configFastProcedureVo);
    }

    /**
     * 根据部门code查询速结程序适用的处罚事项
     *
     * @author yangsizhen
     * @date 2022/12/28
     * @param orgCode 部门code
     * @return com.icinfo.framework.common.web.Result<com.icinfo.cloud.provider.punish.config.vo.ConfigFastProcedureVo>
     */
    @GetMapping("/getListByOrgCode")
    public Result<List<ConfigFastCaseMattersVo>> getListByOrgCode(String orgCode){
        List<ConfigFastCaseMattersVo> configFastProcedureVo = configFastCaseMattersService.getListByOrgCode(orgCode);
        return Result.success(configFastProcedureVo);
    }

    /**
     * V1.11.4 描述:根据部门code、适用的处罚事项、caseId查询文书信息
     * @param orgCode
     * @param listCode
     * @return
     */
    @GetMapping("/getDocumentTemplateByListCode")
    public Result<List<ConfigFastProcedureDocumentInfoVo> > getDocumentTemplateByListCode(@RequestParam("orgCode") String orgCode, @RequestParam("listCode") String listCode,@RequestParam("caseId") String caseId){
        List<ConfigFastProcedureDocumentInfoVo> documentInfoVoList = configFastCaseMattersService.getDocumentTemplateByListCode(orgCode, listCode,caseId);
        return Result.success(documentInfoVoList);
    }
}
